﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Admin.aspx.cs" Inherits="LOS.Redirects.Admin" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Redirects Application Admin Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    
    
        <asp:Panel ID="pnlAdmin" runat="server">
            <table border="1" cellpadding="3" cellspacing="0">
                <tr><td style="text-align:center; background-color:#1C5E55; font-weight:bold; color:White" colspan="5"><b>Add New Alias</b></td></tr>
                <tr>
                    <td style="background-color:#E3EAEB">
                        Alias Name <asp:TextBox ID="txtName" runat="server" />
                    </td>
                    <td style="background-color:#E3EAEB">
                        &nbsp;&nbsp;&nbsp;Redirect URL <asp:TextBox ID="txtUrl" Width="300px" runat="server" /> 
                    </td>
                    <td style="background-color:#E3EAEB">
                        &nbsp;&nbsp;&nbsp;Requestor <asp:TextBox ID="txtRequestor" Width="100px" runat="server" /> 
                    </td>
                    <td style="background-color:#E3EAEB">
                        &nbsp;&nbsp;Active <asp:CheckBox ID="chkActive" Checked="true" runat="server" /> 
                    </td>
                    <td style="background-color:#E3EAEB">
                        &nbsp;&nbsp;&nbsp;<asp:Button ID="btnSubmit" Text="Add" runat="server" OnClick="btnSubmit_Click" />
                    </td>
                </tr>
                <tr>
                    <td style="background-color:#E3EAEB" colspan="5">
                        <asp:Label ID="lblError" ForeColor="Red" Visible="False" runat="server" />
                    </td>
                    
                </tr>
            </table>
            <br /><br />
            
            <table border="1" cellpadding="3" cellspacing="0">
                <tr><td style="text-align:center; background-color:#1C5E55; font-weight:bold; color:White" colspan="5"><b>Search for existing alias</b></td></tr>
                <tr>
                    <td style="background-color:#E3EAEB">
                        Alias Name <asp:TextBox ID="txtName_search" runat="server" />
                    </td>
                    <td style="background-color:#E3EAEB">
                        &nbsp;&nbsp;&nbsp;Redirect URL <asp:TextBox ID="txtUrl_search" Width="300px" runat="server" /> 
                    </td>
                    <td style="background-color:#E3EAEB">
                        &nbsp;&nbsp;&nbsp;Requestor <asp:TextBox ID="txtRequestor_search" Width="100px" runat="server" /> 
                    </td>
                    <td style="background-color:#E3EAEB">
                        &nbsp;&nbsp;Active <asp:CheckBox ID="chkActive_search" Checked="true" runat="server" /> 
                    </td>
                </tr>
                <tr>
                    <td style="background-color:#E3EAEB" colspan="4">
                        &nbsp;&nbsp;&nbsp;<asp:Button ID="btnSearch" Text="Search" runat="server" OnClick="btnSearch_Click" />                    
                        &nbsp;&nbsp;&nbsp;<asp:Button ID="btnUpdate" Text="Update" runat="server" 
                            OnClick="btnUpdate_Click" Visible="False" />
                        <asp:HiddenField ID="hidId" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td style="background-color:#E3EAEB" colspan="5">
                        <asp:Label ID="lblError_search" ForeColor="Red" Visible="False" runat="server" />
                    </td>                    
                </tr>
            </table>
            
            <br /><br />
            <asp:GridView ID="gvRedirects" runat="server" 
                datasourceid="SqlDataSource1" 
                AllowSorting="True" 
                AutoGenerateColumns="False" AllowPaging="True" CellPadding="4" 
                ForeColor="#333333" GridLines="None"    
                DataKeyNames="id"       
                >
                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#E3EAEB" />
                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#D9FFEC" />
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:TemplateField ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkEdit" runat="server" CausesValidation="false" CommandName="Edit"
                                Text="Edit"></asp:LinkButton>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="false" CommandName="Update"
                                Text="Update"></asp:LinkButton>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="false" CommandName="Delete"
                                Text="Delete"></asp:LinkButton>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="false" CommandName="Cancel"
                                Text="Cancel"></asp:LinkButton>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="id" HeaderText="ID" SortExpression="id" ReadOnly="True" Visible="False" />
                    <asp:BoundField DataField="name" HeaderText="Alias Name" SortExpression="name" />
                    <asp:BoundField DataField="url" HeaderText="Redirect URL" SortExpression="url" />
                    <asp:BoundField DataField="requestorLogin" HeaderText="Requestor" SortExpression="requestorLogin" />
                    <asp:BoundField DataField="active" HeaderText="Active" SortExpression="active" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" 
                ConnectionString="<%$ ConnectionStrings:sqlConn %>" 
                SelectCommand="SELECT [id], [name], [url], [requestorLogin], [active] FROM [Redirects] ORDER BY [name]"
                UpdateCommand="UPDATE Redirects SET name=@name, url=@url, requestorLogin=@requestorLogin, active=@active WHERE (id=@id)"
                DeleteCommand="DELETE FROM Redirects WHERE (id=@id)"
                runat="server">                
            </asp:SqlDataSource>
       </asp:Panel>
      
      
      
    </div>
    </form>
</body>
</html>
